#include "LRUCache.hpp"

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << " filemame" << std::endl;
        return 1;
    }
    std::string filename = argv[1];
    LRUCache::FileCache fc(filename);
    int count = 0;
    // 依次对不存在的block测试获取
    while(count<10)
    {
        fc.GetBlock(count*4096);
        fc.PrintCache();
        count++;
        sleep(1);
    }

    // 测试对已经存在的block进行获取
    while(true)
    {
        off_t off;
        std::cout << "Please Enter Off# ";
        std::cin >> off;
        auto b = fc.GetBlock(off);
        std::cout << "block addr: " << b->Addr() << std::endl;
        fc.PrintCache();
    }
    return 0;
}
